package top.xtcoder.jdcbase.rbac.service;

import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import top.xtcoder.jdcbase.rbac.entity.Role;

@Service
public class PbRbacRoleServer {
	@Autowired
    private Dao dao;

    /**
     * 根据角色名称和代码获取角色ID
     * @param rolename
     * @return
     */
    public String getName2Id(String rolename){
        String roleid;
        Role role=dao.fetch(Role.class,Cnd.where("name","=",rolename).or("code","=",rolename));
        if(role==null){
            roleid="";
        }else{
            roleid=role.getId();
        }
        return roleid;
    }
}
